/*
 * File:    VariableStore.java
 * Created: 10-Feb-2009
 * Version: $Id$
 *
 * COPYRIGHT (C) 2009, Bitgate Mobile, LLC.  All Rights Reserved.
 *
 * software@bitgatemobile.com
 */

package com.webplasm.store;

import java.util.HashMap;
import java.util.Map;

import com.webplasm.store.VariableContainer.VariableType;

public class VariableStore {
	private Map<String, VariableStoreInterface> variables;
	
	public VariableStore() {
		variables = new HashMap<String, VariableStoreInterface>();
	}
	
	public VariableStoreInterface getVariable(String variable) {
		if (variables.get(variable) != null) {
			return variables.get(variable);
		}
		
		return null;
	}
	
	public VariableStoreInterface getVariable(String variable, VariableType varType) {
		if (variables.get(variable) != null) {
			return variables.get(variable);
		}
		
		VariableStoreInterface vsInterface = varType.getVariableStoreInterface();
		
		variables.put(variable, vsInterface);
		
		return vsInterface;
	}
	
	public void setVariable(String variable, VariableStoreInterface vsInterface) {
		variables.put(variable, vsInterface);
	}
}